use Dosvid
go

insert into Candidat_RangeTerritories(CandidateId,RangeTerritoryId)
select c.Id, c.RangeTerritoryID
from Candidates c
where c.RangeTerritoryID is not null
go